Go to github.com and login using your credentials!
To make a new repository, click the green button.
Name and create your repository, Lab2.
Once you are done, click the green Create repository button.
Now that your repsitory is created, we want to clone this onto our computer.
Copy this link!
Once you have the link copied, open Terminal for Mac or cmd for Windows. (For the purpose of this lab, terminal will be used because that is what we have on our computers!) We wish to go to the directory that we want our repository to be in. To change your directory, use cd to move. If you ever get lost, use type in pwd to see which directory you are in.
When you are in your desired directory, type in the following code in the terminal and replace the url with the one you copied in the previous step.
git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY.git
If you have done this correctly, you should get an output similar to this on your terminal.
With our repository on our local computer, we want to make a change and push it back to GitHub!
To do this, we will add a line to our README file! Enter the following line to your terminal.
echo "I am writing on this markdown file using the command prompt." >> README.md
If we want to check if this actually worked, we can enter this code on the terminal.
git status
It worked! Now we want to save what we did by commiting it to GitHub. Follow the code line by line!
git add -A
git commit -m "My first commit through the command prompt"
git push
All this is doing is adding the change that we made, commiting it so that we are sure we want to make the change, and then pushing it to our repository that we have on GitHub. Once all of this is done, you will see that your repository will be updated on GitHub.
Go to your repository on GitHub and make sure that the change has been made.
Our commit message is there, which means that it has gone through! Congratulations! :-)
Next we are going to use RStudio to connect to GitHub
First, we want to open RStudio and create a new Project.
…and then select “Git”.
When you reach this screen, paste the URL of your new GitHub repository into the box labeled “Repository URL”.
Make sure that your project directory name and location make sense. If you can’t find your projects, then all of your hard work is meaningless.
A good name might be “Lab2”.
Make sure the box labeled “Open in a new session” is checked.
Finaly, click “Create Project”.
This should download the README.md file that we created on GitHub in the previous step. Look in RStudio’s file browser pane for the README.md file.
From RStudio, modify the README.md file by adding in some text. It can say whatever you want.
Now that you’ve made your edits, it’s time to commit them to your repository.
On the next screen, you should notice that it will say something like “your branch is ahead of master by 1 commit.” This is because the changes we’ve made are only saved on your local machine. We need to add them to our cloud based github repository.
To do this, click the “Push” button.
Now that you have gone though all of this…we want you to create a repository named DataVis2018 and add your Lab1 from last week to it. Here are the general steps again:
Good luck!
Hint: You can add files to your repository folder to add them as changes!